package com.zxj.controller;

import com.seventh.common.pojo.R;
import com.zxj.pojo.entity.TbShop;
import com.zxj.pojo.vo.CarVo;
import com.zxj.pojo.vo.ShopVo;
import com.zxj.service.CarService;
import com.zxj.service.CarShopService;
import com.zxj.service.CarTypeService;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @program: clms-seventh
 * @description:
 * @author: 张修杰
 * @create: 2021-07-24 19:53
 **/
@RestController
@RequestMapping("lease/carShop")

public class CarShopController {
    @Resource
    CarShopService carShopService;
    @Resource
    CarService carService;
    @Resource
    CarTypeService carTypeService;
    @ApiOperation(value = "初始化汽车店面信息")
    @PostMapping("initCarShopTable/{currentpage}/{pagesize}")
    public R initCarShopTable(@PathVariable("currentpage") Integer currentpage,
                          @PathVariable("pagesize") Integer pagesize,
                          @RequestBody ShopVo shopVo){
        return carShopService.findAllCarShopPage(currentpage,pagesize,shopVo);
    }
    @ApiOperation(value = "修改汽车信息")
    @PutMapping("updateCarShopById")
    public R updateCarShopById(@RequestBody TbShop tbShop){
        return carShopService.updateCarShopById(tbShop);
    }

    @ApiOperation(value = "修改回显 汽车信息")
    @GetMapping("selectCarShopById/{id}")
    public R selectCarShopById(@PathVariable String id){
        return carShopService.selectCarShopById(id);
    }
    @ApiOperation(value = "新增汽车信息")
    @PutMapping("insertCarShop")
    public R insertCarShop(@RequestBody TbShop tbShop){
        return carShopService.insertCarShop(tbShop);
    }
    @ApiOperation(value = "删除汽车信息")
    @GetMapping("deleteCarShop/{id}")
    public R deleteCarShop(@PathVariable String id){
        return carShopService.deleteCarShop(id);
    }
    @GetMapping("selectAllCarShop")
    public R selectAllCarShop(){ return carShopService.selectAllCarShop();}
    @ApiOperation(value = "查询汽车门店信息")
    @GetMapping("selShops/{areaId}")
    public R selShops(@PathVariable Integer areaId){
        return carShopService.selectAllList(areaId);
    }
    @PostMapping("allCar")
    @ApiModelProperty("查找车辆")
    public R selAllCar(@RequestBody CarVo vo){
        return carService.selByShopId(vo);
    }
    @GetMapping("selectAllCarType")
    public R selectAllCarType(){ return carTypeService.selectAllCarType();}
}
